package com.iwhalecloud.citybrain.flow.platform.manager;

import org.flowable.engine.common.impl.cfg.IdGenerator;
import org.flowable.engine.common.impl.persistence.StrongUuidGenerator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Controller;

/**
 * @author lilh
 * @date 2021/1/4 下午1:43
 */
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Controller.class)})
@EnableAsync
@Import({DefaultMapperScanPathConfiguration.class, DefaultWebScanConfiguration.class})
public class FlowEngineSimpleAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public IdGenerator uuidGenerator() {
        return new StrongUuidGenerator() {
            @Override
            public String getNextId() {
                return super.getNextId().replaceAll("-", "");
            }
        };
    }
}
